const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    contedetailDatant: {},
    type: 1,
    imgWidth:"",
	  imgHeight:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      type: options.type ,
      myLocation: wx.getStorageSync("address-point"),
      order_id: options.order_id
    })
    wx.setNavigationBarTitle({
      title: options.type == '1' ? '个人需求' : '企业需求',
    });
    wx.setNavigationBarTitle({
      title: options.type == '1' ? '个人需求' : '企业需求',
    });
    if(this.data.type == '1') {
      this.getData()
    }else {
      this.getEnterpriseNeed();
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  imgInfo:function(event){
	  this.setData({
		  imgWidth:event.detail.width,
		  imgHeight:event.detail.height
	  })
  },
  // 跳转企业信息
  goEnterpriseInformation() {
    wx.navigateTo({
      url:  `/packageJ/anytime_service/home/enterprise_information/index?id=${this.data.detailData.has_one_enterprise.id}`,
    });
  },
  getData () {
    let form = this.data.type == "1" ? { nid: this.data.order_id } : ""
    let baseUrl = app.getNetAddresss("plugin.be-within-call.frontend.index.need");
    app._postNetWork({
      url: baseUrl,
      data: {
        lng: this.data.myLocation ? this.data.myLocation.point.lng : "",
        lat: this.data.myLocation ? this.data.myLocation.point.lat : "",
        ...form
      },
      success: ({data : { data,result,msg }}) => {
        if (result !== 1) {
          app.tips(msg)
          return false;
        }
        this.setData({
          detailData:data
        })
      }
    });
  },
  // 企业需求详情
  getEnterpriseNeed () {
    let baseUrl = app.getNetAddresss("plugin.be-within-call.frontend.index.enterprise-need");
    app._postNetWork({
      url: baseUrl,
      data: {
        nid : this.data.order_id
      },
      success: ({data : { data,result,msg }}) => {
        if (result !== 1) {
          app.tips(msg)
          return false;
        }
        this.setData({
          detailData:data
        })
      }
    });
  },
})